'''
Created on 26/04/2010

@author: Mar
'''


from threading import Thread

class ThreadResource(Thread):
    
    def __init__(self, threadID, resource):
        Thread.__init__(self)
        self.resource = resource
        self.threadID = threadID
        
     
    def run(self):
        while (True):
            pcb = self.resource.queue.get()
            self.resource.executePCB(pcb)
            priority = pcb.getPriority()
            self.resource.readyQueue.put(pcb)
            if (len(pcb.program.instructions) == pcb.getPC()):
                pcb.toFinished() 